﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IsmsExplorer.Infrastructure.DomainBase;

namespace IsmsExplorer.Model.Documents {
    /// <summary>
    /// Represents all the ISMS-specific documents of a certain type, for a particular project.
    /// This class represents documents that are not tied to a specific ISO 27001 control.
    /// e.g. the ISMS Scope document(s), Statement of Applicability (SoA) etc.
    /// </summary>
    public class IsmsSpecificDocumentation : EntityBase {
        private int _projectID;
        private int _documentTypeID;
        private string _description;        

        private List<IsmsDocumentLink> _documents = new List<IsmsDocumentLink>();

        public IsmsSpecificDocumentation() : base() {
        }

        public int ProjectID {
            get { return _projectID; }
            set { _projectID = value; }
        }

        public int DocumentTypeID {
            get { return _documentTypeID; }
            set { _documentTypeID = value; }
        }

        public string Description {
            get { return _description; }
            set { _description = value; }
        }

        /// <summary>
        /// We are not using the (int) ID property here.
        /// </summary>
        public override int ID {
            get {
                throw new NotImplementedException("IsmsSpecificDocumentation does not Implement the ID property");
            }
            set {
                throw new NotImplementedException("IsmsSpecificDocumentation does not Implement the ID property");
            }
        }

        public IEnumerable<IsmsDocumentLink> Documents {
            get { return _documents.AsReadOnly(); }
            //set { _documents = value; }
        }

        public void AddDocument(IsmsDocumentLink doc) {
#if DEBUG
            foreach (var d in _documents) {
                if (d == doc) {
                    throw new InvalidOperationException("document already added");
                }
            }
#endif
            _documents.Add(doc);
        }

        public void RemoveDocument(IsmsDocumentLink doc) {
            _documents.Remove(doc);
        }

    } // end public class IsmsSpecificDocumentation : EntityBase

}
